<?php

class admin_controller_admin_role extends AdminController {
	/**
	 * 
	 *
	 * @var admin_model_role
	 */
	var $o;
	
	public function __construct($app, $controller, $standalone=true){
		parent::__construct($app, $controller, $standalone);
		$this->o = Model::factory('admin_model_role');
	}
	
	/**
	 * @name 添加角色表单
	 *
	 */
	public function add_form_action(){
		
	}
	
	/**
	 * @name 添加角色
	 *
	 */
	public function add_action(){
		$role = _('role');
		$flag = $this->o->insert($role);
		$this->ret = self::success(array('message'=>($flag?"添加角色成功":"添加角色失败")));
		$this->_renderJSJump();
	}
	
	/**
	 * @name 角色列表
	 *
	 */
	public function list_action(){
		$this->ret = self::success($this->o->selectList());
	}
	
	/**
	 * @name 删除角色
	 *
	 */
	public function delete_action(){
		$flag = $this->o->remove($this->id);
		$this->ret = self::success(array('message'=>($flag?"角色已删除":"角色删除失败")));
		$this->_renderJSJump();
	}
}